<template>
  <div>
      <el-upload
  action="http://47.98.113.244:8889/api/private/v1/upload"
  :on-remove="handleRemove"
  :on-success='hanleSueecss'
  list-type="picture"
  :headers='headersObj'>
  <el-button size="small" type="primary">点击上传</el-button>
  <div slot="tip" class="el-upload__tip"><p>只能上传jpg/png文件，且不超过500kb</p>
    <p>该选项为选填项</p>
  </div>
</el-upload>
  </div>
</template>

<script>
export default {
        name:'GoodsImgForm',
        data(){
            return {
                headersObj:{
                    Authorization:localStorage.getItem('token')
                },
                pics:[],
                deleteIndex:0
            }
        },
        methods:{
            hanleSueecss(res){
                const picinfo={pic:''}
                picinfo.pic=res.data.tmp_path
                this.pics.push(picinfo)
                console.log(this.pics);
            },
            handleRemove(file){
                        this.deleteIndex=this._.findIndex(this.pics,o=>{
                           return o.pic===file.response.data.tmp_path
                       })
                       this._.pullAt(this.pics,this.deleteIndex)
                       console.log(this.pics);
            }
        }
}
</script>

<style>

</style>